package crazy.memory;

import java.lang.ref.SoftReference;


public class SoftReferenceTest
{
	public static void main(String[] args)
	{
		SoftReference<Person1>[] people = new SoftReference[100];
		for (int i = 0; i < people.length; i++)
		{
			people[i] = new SoftReference<Person1>(new Person1(""+i, (i+1)*4%100));
		}
		System.out.println(people[2].get());
		System.out.println(people[4].get());
		System.gc();
		System.runFinalization();
		System.out.println(people[2].get());
		System.out.println(people[4].get());
	}
}

class Person1
{
	String name;
	int age;
	
	public Person1(String name, int age)
	{
		this.name = name;
		this.age = age;
	}
	
	public String toString()
	{
		return "Person[name="+name+", age="+age+"]";
	}
}
